{"ast":null,"code":"import _toConsumableArray from \"@babel/runtime/helpers/esm/toConsumableArray\";\nimport isVisible from './isVisible';\nfunction focusable(node) {\n  var includePositive = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;\n  if (isVisible(node)) {\n    var nodeName = node.nodeName.toLowerCase();\n    var isFocusableElement =\n    // Focusable element\n    ['input', 'select', 'textarea', 'button'].includes(nodeName) ||\n    // Editable element\n    node.isContentEditable ||\n    // Anchor with href element\n    nodeName === 'a' && !!node.getAttribute('href');\n    // Get tabIndex\n    var tabIndexAttr = node.getAttribute('tabindex');\n    var tabIndexNum = Number(tabIndexAttr);\n    // Parse as number if validate\n    var tabIndex = null;\n    if (tabIndexAttr && !Number.isNaN(tabIndexNum)) {\n      tabIndex = tabIndexNum;\n    } else if (isFocusableElement && tabIndex === null) {\n      tabIndex = 0;\n    }\n    // Block focusable if disabled\n    if (isFocusableElement && node.disabled) {\n      tabIndex = null;\n    }\n    return tabIndex !== null && (tabIndex >= 0 || includePositive && tabIndex < 0);\n  }\n  return false;\n}\nexport function getFocusNodeList(node) {\n  var includePositive = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;\n  var res = _toConsumableArray(node.querySelectorAll('*')).filter(function (child) {\n    return focusable(child, includePositive);\n  });\n  if (focusable(node, includePositive)) {\n    res.unshift(node);\n  }\n  return res;\n}\nvar lastFocusElement = null;\n/** @deprecated Do not use since this may failed when used in async */\nexport function saveLastFocusNode() {\n  lastFocusElement = document.activeElement;\n}\n/** @deprecated Do not use since this may failed when used in async */\nexport function clearLastFocusNode() {\n  lastFocusElement = null;\n}\n/** @deprecated Do not use since this may failed when used in async */\nexport function backLastFocusNode() {\n  if (lastFocusElement) {\n    try {\n      // 元素可能已经被移动了\n      lastFocusElement.focus();\n      /* eslint-disable no-empty */\n    } catch (e) {\n      // empty\n    }\n    /* eslint-enable no-empty */\n  }\n}\n\nexport function limitTabRange(node, e) {\n  if (e.keyCode === 9) {\n    var tabNodeList = getFocusNodeList(node);\n    var lastTabNode = tabNodeList[e.shiftKey ? 0 : tabNodeList.length - 1];\n    var leavingTab = lastTabNode === document.activeElement || node === document.activeElement;\n    if (leavingTab) {\n      var target = tabNodeList[e.shiftKey ? tabNodeList.length - 1 : 0];\n      target.focus();\n      e.preventDefault();\n    }\n  }\n}","map":{"version":3,"names":["_toConsumableArray","isVisible","focusable","node","includePositive","arguments","length","undefined","nodeName","toLowerCase","isFocusableElement","includes","isContentEditable","getAttribute","tabIndexAttr","tabIndexNum","Number","tabIndex","isNaN","disabled","getFocusNodeList","res","querySelectorAll","filter","child","unshift","lastFocusElement","saveLastFocusNode","document","activeElement","clearLastFocusNode","backLastFocusNode","focus","e","limitTabRange","keyCode","tabNodeList","lastTabNode","shiftKey","leavingTab","target","preventDefault"],"sources":["/data/messenger.client/node_modules/rc-util/es/Dom/focus.js"],"sourcesContent":["import _toConsumableArray from \"@babel/runtime/helpers/esm/toConsumableArray\";\nimport isVisible from './isVisible';\nfunction focusable(node) {\n  var includePositive = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;\n  if (isVisible(node)) {\n    var nodeName = node.nodeName.toLowerCase();\n    var isFocusableElement =\n    // Focusable element\n    ['input', 'select', 'textarea', 'button'].includes(nodeName) ||\n    // Editable element\n    node.isContentEditable ||\n    // Anchor with href element\n    nodeName === 'a' && !!node.getAttribute('href');\n    // Get tabIndex\n    var tabIndexAttr = node.getAttribute('tabindex');\n    var tabIndexNum = Number(tabIndexAttr);\n    // Parse as number if validate\n    var tabIndex = null;\n    if (tabIndexAttr && !Number.isNaN(tabIndexNum)) {\n      tabIndex = tabIndexNum;\n    } else if (isFocusableElement && tabIndex === null) {\n      tabIndex = 0;\n    }\n    // Block focusable if disabled\n    if (isFocusableElement && node.disabled) {\n      tabIndex = null;\n    }\n    return tabIndex !== null && (tabIndex >= 0 || includePositive && tabIndex < 0);\n  }\n  return false;\n}\nexport function getFocusNodeList(node) {\n  var includePositive = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;\n  var res = _toConsumableArray(node.querySelectorAll('*')).filter(function (child) {\n    return focusable(child, includePositive);\n  });\n  if (focusable(node, includePositive)) {\n    res.unshift(node);\n  }\n  return res;\n}\nvar lastFocusElement = null;\n/** @deprecated Do not use since this may failed when used in async */\nexport function saveLastFocusNode() {\n  lastFocusElement = document.activeElement;\n}\n/** @deprecated Do not use since this may failed when used in async */\nexport function clearLastFocusNode() {\n  lastFocusElement = null;\n}\n/** @deprecated Do not use since this may failed when used in async */\nexport function backLastFocusNode() {\n  if (lastFocusElement) {\n    try {\n      // 元素可能已经被移动了\n      lastFocusElement.focus();\n      /* eslint-disable no-empty */\n    } catch (e) {\n      // empty\n    }\n    /* eslint-enable no-empty */\n  }\n}\n\nexport function limitTabRange(node, e) {\n  if (e.keyCode === 9) {\n    var tabNodeList = getFocusNodeList(node);\n    var lastTabNode = tabNodeList[e.shiftKey ? 0 : tabNodeList.length - 1];\n    var leavingTab = lastTabNode === document.activeElement || node === document.activeElement;\n    if (leavingTab) {\n      var target = tabNodeList[e.shiftKey ? tabNodeList.length - 1 : 0];\n      target.focus();\n      e.preventDefault();\n    }\n  }\n}"],"mappings":"AAAA,OAAOA,kBAAkB,MAAM,8CAA8C;AAC7E,OAAOC,SAAS,MAAM,aAAa;AACnC,SAASC,SAAS,CAACC,IAAI,EAAE;EACvB,IAAIC,eAAe,GAAGC,SAAS,CAACC,MAAM,GAAG,CAAC,IAAID,SAAS,CAAC,CAAC,CAAC,KAAKE,SAAS,GAAGF,SAAS,CAAC,CAAC,CAAC,GAAG,KAAK;EAC/F,IAAIJ,SAAS,CAACE,IAAI,CAAC,EAAE;IACnB,IAAIK,QAAQ,GAAGL,IAAI,CAACK,QAAQ,CAACC,WAAW,EAAE;IAC1C,IAAIC,kBAAkB;IACtB;IACA,CAAC,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,CAAC,CAACC,QAAQ,CAACH,QAAQ,CAAC;IAC5D;IACAL,IAAI,CAACS,iBAAiB;I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